//
//  KCReimAllTypeView.swift
//  MyKC
//
//  Created by yy on 2017/2/23.
//  Copyright © 2017年 com.yasuo. All rights reserved.
//

import UIKit

class KCReimAllTypeView: UIView {
    var typeArray: [KCReimTypeModel]? {
        //外界已经完成了的赋值
        didSet {
         pickerView.reloadAllComponents()
        }
    }
    @IBOutlet weak var pickerView: UIPickerView!
    @IBOutlet weak var cancelBtn: UIButton!
    @IBOutlet weak var sureBtn: UIButton!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        pickerView.backgroundColor = UIColor.clear
        pickerView.delegate = self
        pickerView.dataSource = self
    }
    
    class func reimAllTypeView() -> KCReimAllTypeView {
        return Bundle.main.loadNibNamed("KCReimAllTypeView", owner: nil, options: [:])?.last as! KCReimAllTypeView
    }

}

extension KCReimAllTypeView: UIPickerViewDelegate,UIPickerViewDataSource {
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return typeArray?.count ?? 0
    }
    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        let name = typeArray?[row].Name
        return name ?? ""
    }
}
